package com.loyi.ams.gateway.hbmis.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.loyi.cloud.hbmis.domain.RealData;

@Mapper
public interface IRealDataDAO {

	@Select("SELECT * FROM t_bas_data_main WHERE datatime=#{datatime} AND ptid=#{ptid} AND pollcode=#{pollcode} LIMIT 0,1")
	public RealData find(@Param("datatime") long datatime, @Param("ptid") String ptid,
			@Param("pollcode") String pollcode);

	@Update("UPDATE t_bas_data_main SET value=#{data.value},realvalue=#{data.value},status=#{data.status},uploadtime=#{data.uploadtime} WHERE datatime=#{data.datatime} AND dataid=${data.dataid} ")
	public void update(@Param("data") RealData data);

	@Insert("INSERT INTO t_bas_data_main(datatime,uploadtime,ptid,deviceid,channelid,pollcode,value,realvalue,status,protocol) VALUES (#{data.datatime},#{data.uploadtime},#{data.ptid},#{data.deviceid},#{data.channelid},#{data.pollcode},#{data.value},#{data.value},#{data.status},#{data.protocol})")
	public void insert(@Param("data") RealData data);
}
